package com.lou1052.redis.jedis.ext.client.single;

import com.lou1052.core.serializer.Serializer;
import com.lou1052.redis.jedis.api.JedisApi;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisShardInfo;
import redis.clients.util.IPool;

import java.net.URI;
import java.util.function.Function;

/**
 *
 * Created with IntelliJ IDEA.
 * User: liuqing
 * Date: 2015/10/25
 * Time: 8:28
 * To change this template use File | Settings | File Templates.
 */
public class JedisExt extends Jedis implements JedisApi{

    @Override
    public void setDataSource(IPool jedisPool) {
        this.dataSource = jedisPool;
    }

    public void setSerializerFunction(Function<String, Serializer> serializerFunction) {
        this.serializerFunction = serializerFunction;
    }

    @Override
    public Serializer getSerializer(String key) {
        return serializerFunction.apply(key);
    }

    public JedisExt(Function<String, Serializer> serializerFunction) {
        this.serializerFunction = serializerFunction;
    }

    public JedisExt(String host, Function<String, Serializer> serializerFunction) {
        super(host);
        this.serializerFunction = serializerFunction;
    }

    public JedisExt(String host, int port, Function<String, Serializer> serializerFunction) {
        super(host, port);
        this.serializerFunction = serializerFunction;
    }

    public JedisExt(String host, int port, int connectionTimeout, int soTimeout, Function<String, Serializer> serializerFunction) {
        super(host, port, connectionTimeout, soTimeout);
        this.serializerFunction = serializerFunction;
    }

    public JedisExt(String host, int port, String passWord, Function<String, Serializer> serializerFunction) {
        super(host, port, passWord);
        this.serializerFunction = serializerFunction;
    }

    public JedisExt(String host, int port, String passWord, int connectionTimeout, int soTimeout, Function<String, Serializer> serializerFunction) {
        super(host, port, passWord, connectionTimeout, soTimeout);
        this.serializerFunction = serializerFunction;
    }

    public JedisExt(String host, int port, int timeout, Function<String, Serializer> serializerFunction) {
        super(host, port, timeout);
        this.serializerFunction = serializerFunction;
    }

    public JedisExt(JedisShardInfo shardInfo, Function<String, Serializer> serializerFunction) {
        super(shardInfo);
        this.serializerFunction = serializerFunction;
    }

    public JedisExt(URI uri, Function<String, Serializer> serializerFunction) {
        super(uri);
        this.serializerFunction = serializerFunction;
    }

    public JedisExt(URI uri, int connectionTimeout, int soTimeout, Function<String, Serializer> serializerFunction) {
        super(uri, connectionTimeout, soTimeout);
        this.serializerFunction = serializerFunction;
    }

    public JedisExt(URI uri, int timeout, Function<String, Serializer> serializerFunction) {
        super(uri, timeout);
        this.serializerFunction = serializerFunction;
    }

    public JedisExt() {
    }

    public JedisExt(String host) {
        super(host);
    }

    public JedisExt(String host, int port) {
        super(host, port);
    }

    public JedisExt(String host, int port, int connectionTimeout, int soTimeout) {
        super(host, port, connectionTimeout, soTimeout);
    }

    public JedisExt(String host, int port, String passWord) {
        super(host, port, passWord);
    }

    public JedisExt(String host, int port, String passWord, int connectionTimeout, int soTimeout) {
        super(host, port, passWord, connectionTimeout, soTimeout);
    }

    public JedisExt(String host, int port, int timeout) {
        super(host, port, timeout);
    }

    public JedisExt(JedisShardInfo shardInfo) {
        super(shardInfo);
    }

    public JedisExt(URI uri) {
        super(uri);
    }

    public JedisExt(URI uri, int connectionTimeout, int soTimeout) {
        super(uri, connectionTimeout, soTimeout);
    }

    public JedisExt(URI uri, int timeout) {
        super(uri, timeout);
    }
}
